#ifndef N1LIST_H_2006_07_29
#define N1LIST_H_2006_07_29

#include "N1Lib.h"

class N1ListItem {
public:
    N1Object   *item;
    N1ListItem *next;
    N1ListItem *prev;

    N1ListItem(N1Object *_item, N1ListItem *_next, N1ListItem *_prev);
    ~N1ListItem();
};

typedef N1ListItem* N1POSITION;

class NEXPORT N1List : public N1Object {
protected:
    N1ListItem *m_pHead;
    N1ListItem *m_pTail;
    N1UInt32    m_nCount;

public:
    N1List();
    N1List(N1List *list);
    //N1List(N1Array *array);

    N1NAME(N1List)

    N1DESC

    void addHead(N1Object *obj);
    void addTail(N1Object *obj);

    void removeAll( );

    N1Object* removeHead( );
    N1Object* removeTail( );

    void removeAt(N1POSITION position);

    const N1Object* getHead( ) const;
    N1Object* getHead( );

    const N1Object* getTail( ) const;
    N1Object* getTail( );

    N1POSITION getHeadPosition( ) const ;
    N1POSITION getTailPosition( ) const ;

    N1Object* getNext(N1POSITION& rPosition);
    const N1Object* getNext(N1POSITION& rPosition) const ;

    N1Object* getPrev(N1POSITION& rPosition);
    const N1Object* getPrev(N1POSITION& rPosition) const ;

    N1Object* getAt(N1POSITION position);
    const N1Object* getAt(N1POSITION position) const;

    void setAt(N1POSITION pos, N1Object* obj);

    N1POSITION insertAfter(N1POSITION position, N1Object* obj);
    N1POSITION insertBefore(N1POSITION position, N1Object* obj);

    N1POSITION find(N1Object* obj, N1POSITION startAfter = NULL) const;
    N1POSITION findIndex(N1UInt32 nIndex) const;

    N1UInt32 getCount() const;
    N1UInt32 getSize( ) const;

    BOOL isEmpty( ) const;
};

#endif //N1LIST_H_2006_07_29
